﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using WPFExcelReport.Helpers;
using System.ComponentModel;
namespace WPFExcelReport
{
    public partial class TGS03
    {


        public TGS03()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VGSDAT();
            DataContext = MV;
            InitializeComponent();
        }
        public override void LOADBYAUF()
        {
            if (!IsCanLoad)
                return;
            TBMain.Clear();
            if (ORDERNUM.Length < 23)
                return;
            dwData = TBMain.NewRow();
            dwData["GSMANDANT"] = app.Mandant;
            dwData["GSART"] = ORDERNUM.Substring(1, 20);
            dwData["GSVAR"] = ORDERNUM.Substring(21, 3);
            SResult = TMV.QGS01(dwData);
            MergeData(SResult, true);
            base.LOADBYAUF();
        }
        public override void OnSave()
        {

            if (!IsSaved)
                return;
            if (dwMaster == null)
                return;
            TMV.UpdateGSDAT(dwMaster, 0);
            string key = KEY;
            KEY = "";
            KEY = key;
            base.OnSave();
        }
        public override void OnCOUNTTYPChg()
        {
            if (!IsEdit)
                return;
            if (dwMaster == null)
                return;
            if (COUNTTYP.Length < 4)
                return;
            TMV.GSNUMART = COUNTTYP;
            TMV.GSRECHNUM = COUNTTYP;
            base.OnCOUNTTYPChg();
        }
        public override void OnFERTKZChg()
        {
            if (!IsEdit)
                return;
            if (dwMaster == null)
                return;
            if (FERTKZ.Length<1)
                return;
            TMV.GSFERTKZ = FERTKZ; 
            base.OnFERTKZChg();
        }
    }
}
